package com.ghy.entity;

import com.mybatisflex.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户表 实体类。
 *
 * @author ghy
 * @since 2024-12-22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "user", schema = "ml_ums")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 账号
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 省份
     */
    private String province;

    /**
     * 姓名
     */
    private String realname;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 星座
     */
    private String zodiac;

    /**
     * 手机
     */
    private String phone;

    /**
     * 身份证号
     */
    private String idcard;

    /**
     * 描述
     */
    private String info;

    /**
     * 性别，0女，1男，2保密
     */
    private Integer gender;

    /**
     * 年龄
     */
    private Integer age;

    /**
     * 数据版本
     */
    @Column(version = true)
    private Long version;

    /**
     * 逻辑删除，0未删除，1已删除
     */
    @Column(isLogicDelete = true)
    private Integer deleted;

    /**
     * 创建时间
     */
    private LocalDateTime created;

    /**
     * 修改时间
     */
    private LocalDateTime updated;

    /** 用户[N]：角色[N] */
    @RelationManyToMany(
            selfField = "id",
            targetField = "id",
            joinTable = "user_role",
            joinSelfColumn = "fk_user_id",
            joinTargetColumn = "fk_role_id"
    )
    private List<Role> roles;

}

